<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.w3.org/1999/xhtml">
<head>
    <th:block th:include="include :: header('人员日报')"/>
</head>
<body class="gray-bg">
<div class="ui-layout-center">
    <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="report-form">
                    <div class="select-list">
                        <ul>
<!--                            <li>-->
<!--                                名字：<input type="text" name="staffName"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                岗位：<input type="text" name="staffStation"/>-->
<!--                            </li>-->
<!--                            <li>-->
<!--                                在位情况：<select name="staffStatus">-->
<!--                                <option value="">请选择在位情况</option>-->
<!--                                <option value="在岗">在岗</option>-->
<!--                                <option value="出差">出差</option>-->
<!--                                <option value="请假">请假</option>-->
<!--                                <option value="调休">调休</option>-->
<!--                            </select>-->
<!--                            </li>-->
                            <li class="select-time">
                                <label>时间范围： </label>
                                <input type="text" class="time-input" id="startTime" placeholder="开始时间" name="startTime"/>
                                <span>-</span>
                                <input type="text" class="time-input" id="endTime" placeholder="结束时间" name="updateTime"/>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                        class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                        class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.addTab()">
                    <i class="fa fa-plus"></i> 新增
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.editTab()"
                   shiro:hasPermission="system:user:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()"
                   shiro:hasPermission="system:user:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:user:import">
                    <i class="fa fa-upload"></i> 导入
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:user:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>
            <!--表单-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
</div>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "system/report";
    $(function () {
        var options = {
            url: prefix + "/list",
            createUrl: prefix + "/add",
            updateUrl: prefix + "/edit/{id}",
            removeUrl: prefix + "/delete",
            exportUrl: prefix + "/export",
            clickToSelect: true,//是否启用点击选中行
            importUrl: prefix + "/importData",
            modalName: "日报",
            columns: [{
                checkbox: true
            },
                {
                    field: 'reportId',
                    title: '日报编号'
                },
                {
                    field: 'staffName',
                    title: '员工名字'
                },
                {
                    field: 'staffStation',
                    title: '员工岗位'
                },
                {
                    field: 'staffStatus',
                    title: '在位情况'
                },
                {
                    field: 'todayPlan',
                    title: '今日计划'
                },
                {
                    field: 'finishWork',
                    title: '已完成事项'
                },
                {
                    field: 'notDoWork',
                    title: '未完成事项'
                },
                {
                    field: 'startTime',
                    title: '开始时间'
                },
                {
                    field: 'updateTime',
                    title: '更新时间'
                },
                {
                    field: 'staffProgress',
                    title: '工作进度',
                },
                {
                    field:'flag',
                    title:'是否更新',
                    formatter:function (value,row,index){
                        if (value == "1"){
                            return "是";
                        }else{
                            return "否";
                        }
                    }
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function (value, row, index) {
                        console.log(row)
                        var actions = [];
                        actions.push('<a class="btn btn-success btn-xs" href="javascript:void(0)" onclick="editTime(\'' + row.reportId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
                        actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.reportId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
        };
        /*初始化表格参数*/
        $.table.init(options);

    });

</script>
<script type="text/javascript">
    function editTime(id) {
        $.ajax({
            type: "GET",
            async: true,
            url: $.operate.editUrl(id),
            success: function (data) {
                console.log(data);
                if (data != "false") {
                    $.modal.openTab("修改" + table.options.modalName, $.operate.editUrl(id));
                } else {
                    $.modal.alert("当前时间段不可以编辑!",modal_status.WARNING);
                }
            }
        });
    }
</script>
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
    <form enctype="multipart/form-data" class="mt20 mb10">
        <div class="col-xs-offset-1">
            <input type="file" id="file" name="file"/>
            <div class="mt10 pt5">
                <input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在，更新这条数据。"> <!--是否更新已经存在的日报数据-->
                &nbsp;	<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
            </div>
            <font color="red" class="pull-left mt10">
                提示：仅允许导入“xls”或“xlsx”格式文件！
            </font>
        </div>
    </form>
</script>
</html>